<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="请输入1-100之间的整数" v-model="num">
    <input type="button" value="猜一猜" @click="f()">
    <h1>{{info}}</h1>
</div>

<script src="js/vue.min.js"></script>
<script>

    let flag = parseInt(Math.random() * 100 + 1);
    console.log(flag);
    let count = 0;
    let v = new Vue({
        el: "body>div",
        data: {
            num: "",
            info: ""
        },
        methods: {
            f() {
                count++;
                if (v.num > flag) {
                    v.info = '你猜大了'
                } else if (v.num < flag) {
                    v.info = '你猜小了'
                } else {
                    v.info = "你真厉害,只用了" + count + "次就猜对了";
                    flag = parseInt(Math.random() * 100 + 1);
                    num = 0;
                    console.log(flag, num);
                }
            }
        }
    })
</script>
</body>
</html>